package com.example.mykotilin.room.persistence

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.reactivex.Completable
import io.reactivex.Flowable

@Dao
interface UserDao {

    /**
     * 通过userid查找user
     *
     */
    @Query("SELECT * FROM Users WHERE userid = :id")
    fun getUserById(id:String) :Flowable<User>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun  insertUser(user:User):Completable

    /**
     * 删除所有的用户
     */
    @Query("DELETE FROM Users")
    fun deleteAllUsers()
}